var Update = {

	REMOVE_URL : "/company/pages/remove",
	BAN_URL : "/company/pages/ban",
	UNBAN_URL : "/company/pages/unban",

	removeIds : function getRemoveIds() {
		allRemoves = [];
		$('td.for-remove :checked').each(function() {
			allRemoves.push($(this).val());
		});
	},

	banUnbanIds : function getBanUnbanIds() {
		allBansUnbans = [];
		$('td.for-ban-unban :checked').each(function() {
			allBansUnbans.push($(this).val());
		});
	},

	usersRemove : function remove() {
		Update.removeIds();
		jQuery.ajax({
			type : "POST",
			async : false,
			cashe : false,
			url : Update.REMOVE_URL,
			data : "remove=" + allRemoves,
			beforeSend : function() {
			},
			complete : function() {
			},
			success : function(data) {
				location.reload();
			},
			error : function() {
				location.reload();
			}
		});
	},

	usersBan : function ban() {
		Update.banUnbanIds();
		jQuery.ajax({
			type : "POST",
			async : false,
			cashe : false,
			url : Update.BAN_URL,
			data : 'ban=' + allBansUnbans,
			beforeSend : function() {
			},
			complete : function() {
			},
			success : function(data) {
				location.reload();
			},
			error : function() {
				location.reload();
			}
		});
	},

	usersUnban : function unban() {
		Update.banUnbanIds();
		jQuery.ajax({
			type : "POST",
			async : false,
			cashe : false,
			url : Update.UNBAN_URL,
			data : 'unban=' + allBansUnbans,
			beforeSend : function() {
			},
			complete : function() {
			},
			success : function(data) {
				location.reload();
			},
			error : function() {
				location.reload();
			}
		});
	}
};

$(document).ready(function() {

	$('#contentbody :checked').each(function() {
		$(this).removeAttr("checked");
	});

	$("#remove").click(function() {
		Update.usersRemove();
	});

	$("#ban").click(function() {
		Update.usersBan();
	});

	$("#unban").click(function() {
		Update.usersUnban();
	});

});